package com.wenjie.original.entity;

import com.mybatisflex.annotation.EnumValue;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.wenjie.common.enumHandler.IEnum;
import com.wenjie.original.entity.common.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.util.Arrays;

@Data
@Table("sys_dict_data")
@ApiModel("字典数据表")
public class SysDictData extends BaseEntity {

    @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
    private Long sysDictDataId;

    @ApiModelProperty("")
    private Long dictCode;

    @ApiModelProperty("字典排序")
    private Long dictSort;

    @ApiModelProperty("字典标签")
    private String dictLabel;

    @ApiModelProperty("字典键值")
    private String dictValue;

    @ApiModelProperty("字典类型")
    private String dictType;

    @ApiModelProperty("样式属性（其他样式扩展）")
    private String cssClass;

    @ApiModelProperty("表格字典样式")
    private String listClass;

    @ApiModelProperty("是否默认（Y是 N否）")
    private Boolean isDefault;

    @ApiModelProperty("状态（0正常 1停用）")
    private STATUS status;


    @Getter
    @AllArgsConstructor
    public enum STATUS implements IEnum<Integer> {
        arg0(0, "正常"),
        arg1(1, "异常");

        @EnumValue
        private Integer code;
        private String message;

        /**
         * @Description 通过code进行查询枚举值
         * @author wenjie
         * @date 2024/5/30 15:21
         */
        public static STATUS getBycode(Integer code) {
            return Arrays.stream(STATUS.values()).filter(s -> s.getCode().equals(code)).findFirst().orElse(null);
        }
    }
}
